package cn.mugutu.finance.domain.system;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name = "sys_department")
@Data
public class Department extends BaseEntity {
    private static final long serialVersionUID = 1L;

    private String name;

    @ManyToOne
    @JoinColumn(name = "parentId")
    @JSONField(serialize = false)
    private Department parent;

    @OneToMany(mappedBy = "parent")
    private Set<Department> children = new HashSet<>();


}
